﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xyz.Service;
using Xyz.Service.DataTransferObjects;

namespace Xyz.Web.Admin.Agent
{
    public partial class CreateAgent : System.Web.UI.Page
    {
        CustomerService customerService = new CustomerService();
        
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            AgentDTO agentDTO = new AgentDTO();
            agentDTO.UserName = txtUsername.Text;
            agentDTO.Password = txtPassword.Text;
            agentDTO.FirstName = txtFirstName.Text;
            agentDTO.LastName = txtLastName.Text;
            agentDTO.Gender = (rdbMale.Checked) ? "M" : "F";
            agentDTO.DateOfBirth = DateTime.Parse(txtDob.Text);
            agentDTO.RoleId = 1;
            agentDTO.CompanyName = txtCompanyName.Text;
            agentDTO.DiscountRate = Convert.ToDecimal(txtDiscountRate.Text);

            customerService.CreateCustomer(agentDTO);
            Response.Redirect("../Flight/SearchFlightSchedule.aspx");
        }
    }
}